from django.db import models

class User(models.Model):
    username=models.CharField(max_length=100)
    password=models.CharField(max_length=100)
class spfltable(models.Model):
    spflname=models.CharField(max_length=100)
    spflid=models.ForeignKey("self",null=True,on_delete=models.SET_NULL,related_name="handers1")
    create_time=models.DateTimeField(auto_now_add=True)

class sptable(models.Model):
    spname=models.CharField(max_length=100)
    spfl=models.ForeignKey(spfltable,on_delete=models.CASCADE,related_name="handers2")
    price = models.DecimalField(max_digits=10, decimal_places=2)
    num = models.IntegerField()
    create_time = models.DateTimeField(auto_now_add=True)
    unique_time=models.DateTimeField(auto_now=True)
class order(models.Model):
    sp=models.ForeignKey(sptable,on_delete=models.CASCADE,related_name="handers3")
    num=models.IntegerField()
    diprice=models.DecimalField(max_digits=10,decimal_places=2)
    kname=models.CharField(max_length=100)
    yongid=models.ForeignKey(User,on_delete=models.CASCADE,related_name="handers4")
    xdtime=models.DateTimeField(auto_now_add=True)